package com.controller.system;

import com.common.core.controller.BaseController;
import com.common.utils.AjaxResult;
import com.system.entity.SystemMenuEntity;
import com.system.service.SystemMenuService;
import com.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 系统菜单表
 *
 * @author yangzhan
 * @email *****@mail.com
 * @date 2022-04-02 19:00:58
 */
@Controller
@RequestMapping()
public class SystemMenuController extends BaseController {

    @Autowired
    private SystemMenuService systemMenuService;


    /**
     * 跳转到页面
     */
    @GetMapping("/systemMenu/list")
    public String temMenu() {
        return "system/systemmenu/list" ;
    }

    /**
     * 系统菜单表 添加
     */
    @PostMapping("/systemMenu/add")
//    @RequiresPermissions("system:menu:add")
    @ResponseBody
    public AjaxResult add(@RequestBody SystemMenuEntity systemMenuEntity) {

        return systemMenuService.temMenuAdd(systemMenuEntity);
    }

    /**
     * 系统菜单表
     *
     * @param ids
     */
    @DeleteMapping("/systemMenu/delete")
    @ResponseBody
    public AjaxResult delete(@RequestBody List<Integer> ids) {
        return systemMenuService.temMenuDel(ids);
    }

    /**
     * 更新数据
     */
    @PutMapping("/systemMenu/update")
    @ResponseBody
    public AjaxResult update(@RequestBody SystemMenuEntity systemMenuEntity) {
        return systemMenuService.temMenuUpById(systemMenuEntity);
    }

    /**
     * 数据查询
     */
    @PostMapping("/systemMenu/listByPage")
    @ResponseBody
    public AjaxResult findListByPage(@RequestBody SystemMenuEntity systemMenuEntity) {
        return systemMenuService.temMenuSelectListByPage(systemMenuEntity);
    }

    /**
     * 目录
     *
     * @return
     */
    @RequestMapping("/systemMenu/menu")
    @ResponseBody
    private Map<String, Object> menuTo(UserVO user) {
        return systemMenuService.menuTo(user);
    }

    /**
     * 菜单管理列表
     *
     * @return
     */
    @RequestMapping("/systemMenu/menuGuan")
    @ResponseBody
    public AjaxResult menuGuan() {
        return systemMenuService.menuGuan();
    }


}
